package com.xiaohu.mayi_huiyuan.controller;

import com.xiaohu.mayi_huiyuan.entity.Customer;
import com.xiaohu.mayi_huiyuan.model.CustomerDto;
import com.xiaohu.mayi_huiyuan.model.HuiZong;
import com.xiaohu.mayi_huiyuan.model.YueBiaoDto;
import com.xiaohu.mayi_huiyuan.service.QueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class QueryController {

    @Autowired
    private QueryService queryService;

    /**
     * 获取所有用户
     *
     * @return
     */
    @RequestMapping("/inCustomerTable")
    public String getAllCustomer(ModelMap mode) {
        List<CustomerDto> list = queryService.getCustomerList();
        mode.put("customerlist", list);
        mode.put("count", list.size());
        return "customertable";
    }

    /**
     * 获取余额表
     *
     * @return
     */
    @RequestMapping("/getAllYue")
    public String getAllYue(ModelMap mode)throws Exception {
        List<YueBiaoDto> list = queryService.getAllYue();
        HuiZong huiZong=queryService.getHuiZong();
        mode.put("yuebiao",list);
        mode.put("huizong",huiZong);
        mode.put("count",huiZong.getCount());
        return "xiaofeitable";
    }

}
